use std::collections::HashMap;

#[test]
fn map_first_test() {
    let mut m = HashMap::new();
    m.insert("tom", "hello");
    m.insert("jerry", "world");

    println!("has tom {:?}", m.contains_key("tom"));

    println!("m {:?}", m);
    for (k, v) in &m {
        println!("k = {:?}, v = {:?}", k, v);
    }
}

#[test]
fn map_wordcount_test() {
    let text = "a short treatise on fungi";
    let mut wc = HashMap::new();
    for c in text.chars() {
        let e = wc.entry(c).or_insert(0);
        *e += 1
    }
    for (k, v) in wc {
        println!("char = {:?}, num = {:?}", k, v);
    }
}
